<!DOCTYPE html>
<html lang="zh">
<head>
    <script type="text/javascript" src="https://cdn.goeasy.io/goeasy.js"></script>
    ${FrontStyle}
</head>
<body >
<div id="sid">$sid</div>
<div id="lid">$lid</div>
<div id="encryptionId">${login.encryptionId}</div>
</br>
ajaxRequestGetKey:<div id="lid" value='${lid}'>${lid}</div>
</br>
goEasyGetKey:<div id="goEasyGetKey" >${lid}</div>
</br>
<div id="login">login</div>
${LoginMsg}
</br>

</body>

<script >
    if(window.WebSocket){
//alert('can exe WebSocket'+$("#sid").html());41B73719DE0FF906075DB4F0DC4E57AD
    }
    var ws = new WebSocket("ws:/localhost:8080/playViews/$sid/"+$lid+"/webSocket");

    ws.onopen = function()

    {  console.log("open");

        ws.send("hello");

    };

    ws.onmessage = function(evt)

    {

        console.log(evt.data);
        alert(evt.data);
        if(evt.data==1){
            alert('账号已在其他地方登录');
            window.location.href="loginPage?backurl="+window.location.href;
        }

    };

    ws.onclose = function(evt)

    {

        console.log("WebSocketClosed!");

    };

    ws.onerror = function(evt)

    {

        console.log("WebSocketError!");

    };


    //goeasy接收信息
    var goEasy = new GoEasy({appkey: 'BC-342dbd217d414bbf9312a58b237a358a'});
    goEasy.subscribe({
        channel: "wsf",
        onMessage: function(message){
            $("#goEasyGetKey").html(message.content);
        }
    });
    var lid=$("#lid").attr("value");
    $("#login").click(function(){
        var url='http://localhost:8080/playViews/play/'+lid+'/index.fruit_slayer';
        var data={nickName:"shaoDog",passWord:"666",id:"173"};
        var mydata=  JSON.stringify(data);
        alert(url);
        var jq = $.noConflict();
        jq.ajax({
            type : 'POST',
            //	contentType : 'application/json',
            url : url,
            processData : false,
            dataType : 'json',
            //	data : mydata,
            success : function(data) {

                alert("requestOldkey: " + data.requestOldkey );
                $("#login").html("ajaxrequest:${lid}");

            },
            error : function(data) {
                alert(data.status);
            }
        });

    });
</script>

<p></p>

<button class="btn1">改变所有 p 元素的文本内容</button>

<script type="text/javascript">
    //定时器 每3s发送一次请求通过session检验有无后一个登陆者
    setInterval(function(){

        /**
         jQuery.get(

         '/playViews/otherAgainLogin/'+${lid}+'/check',
         function(data){
				if(data.status!= undefined&&data.status!=200||data.msg==1){
				window.location.href="loginPage?backurl="+window.location.href;
				}
				//var data = eval('(' + data + ')');
				$("#lid").html(lid);
				 lid=data.lid;
			});**/

        /** 	var jq = $.noConflict();//请求第二次没有反应执行不了 不是缓存的原因。。。
         jQuery.ajax({
				cache:false,
				url : myDate2+'/checkNewLogin',
				success : function(data) {
					alert(data.msg);

				},
				error : function(data) {
					alert(data.status);
				}
			});*/
    }, 6000);

    $(document).ready(function(){
        $(".btn1").click(function(){

        });
    });

</script>
</html>
